<?php include '_init_.php';?>
<?php
$id = intval($_REQUEST['id']);
$orderManager = Order_Manager::getOrderManager($id);
if($orderManager == null)
	exit("Not exist");
if($orderManager->getStatus() != Order_Manager::$STATUS_SAVED)
	exit("Not allowed");
$orderManager->init();
if($orderManager->getOrderStatus() != 'cancel')
	exit("Not allowed");
	
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';
if($act == 'setstatus')
{
	$orderManager->setOrderStatus($_REQUEST['status']);
	$orderManager->persistOrderInfo();
	ob_clean();
	if($_REQUEST['status'] == 'new')
	{
		header('Location:cos.php?id='.$orderManager->getId());
	}
	exit();
}
$orderInfo = $orderManager->getInfo();
?>
<?php include 'page_header.php';?>
<script language="javascript">
function edit_tol(id) {
		rAlert("cosil.php?id=<?php echo $orderManager->getId();?>" , null, "消費明細", 704,704 );
}
</script>
<div id="main"><!-- start #main //-->
<div id="tita">
  <div class="tita-1">
    <h3>預約資訊</h3>
  </div>
  <div class="tita-2"><?php echo date(constant('WEBSITE_DATE_FORMATE'),strtotime($orderInfo['created']));?></div>
  </div>
  <div id="maina" class="clearfix"><!-- start #maina //-->
   <div class="maina-2">
    <ul>
      <li class="maina-1a">
        預約門市<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['department']);?></li>
      <li class="maina-1a">
         預約單號<img src="images/line3.gif" width="21" height="12" />NO.<?php echo Util::html_safe($orderInfo['number']);?></li>
      <li class="maina-1a">
         業務人員<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['department_worker']);?></li>
         
    </ul>
    </div>
  <div class="maina-2">
    <ul>
      <li class="maina-1a">
        姓名<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['customerinfo']['name']);?></li>
      <li class="maina-1a">
         生日<img src="images/line3.gif" width="21" height="12" /><?php printf("民國 %s年 %s月 %s日",$orderInfo['customerinfo']['birthday']['year'],$orderInfo['customerinfo']['birthday']['month'],$orderInfo['customerinfo']['birthday']['date'])?>
      </li>
      <li class="maina-1a">
        電話<img src="images/line3.gif" width="21" height="12" />(<?php echo Util::html_safe($orderInfo['customerinfo']['tel']['part_one']);?>)<?php echo Util::html_safe($orderInfo['customerinfo']['tel']['part_two']);?>
      </li>
      <li class="maina-1a">
       手機<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['customerinfo']['mobile']);?>
      </li>
    </ul>
    </div>
    <div class="maina-2">
    <ul>
       <li class="maina-1b">電郵2<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['customerinfo']['email']);?>
      </li>
      <li class="maina-1b">
       地址<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['customerinfo']['address']['part_one']);?><?php echo Util::html_safe($orderInfo['customerinfo']['address']['part_two']);?><?php echo Util::html_safe($orderInfo['customerinfo']['address']['part_three']);?>
      </li>
      <li class="maina-1b">電郵2<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['customerinfo']['email2']);?>
      </li>
    </ul>
    </div>
     <div class="maina-2">
     <ul>
      <li class="maina-1a">
        預約類別<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['type']);?></li></li>
      <li class="maina-1a">
       數位光碟<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['disk_number']);?>組
      </li>
        <li class="maina-1a">
        相本<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['benzu_style']);?></li>
        <li class="maina-1a">
        相本數量<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['benzu_number']);?></li>
    </ul>
    </div>
    
     <div class="maina-2">
    <ul>
      <li class="maina-1a" style="width:300px;">
        拍攝人數（成人）<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['person_number']);?>人</li>
      <li class="maina-1a" style="width:300px;">
       服裝造型（成人）<img src="images/line3.gif" width="21" height="12" /> <?php echo Util::html_safe($orderInfo['dress_number']);?>套 </li>
         <li class="maina-1a" style="width:300px;">
        拍攝人數（小孩）<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($orderInfo['person_number2']);?>人</li>
      <li class="maina-1a" style="width:300px;">
       服裝造型（小孩）<img src="images/line3.gif" width="21" height="12" /> <?php echo Util::html_safe($orderInfo['dress_number2']);?>套 </li>

    </ul>
    </div>
    <div class="maina-2">
    <ul>
    	<?php $sizeNameMap = array(); ?>
     	<?php foreach($orderInfo['zoom_list'] as $tmpData):?>
     		<?php $sizeNameMap[$tmpData['size_id']] = $tmpData['size_name'];?>
     		 <li class="maina-1a"><?php echo  Util::html_safe($tmpData['size_name']);?> 吋 X <?php echo  Util::html_safe($tmpData['number']);?> <?php if($tmpData['is_gift'] == 'Y'):?>
     		 <span> (贈品) </span>
     		 <?php endif;?></li>
     	<?php endforeach;?>  
    </ul>
    </div>
     <div class="maina-2">
    <ul>
     	
     	<?php foreach($orderInfo['zoom_frame_list'] as $tmpIndex=>$tmpData):?>
     <li class="maina-1j"><?php echo  Util::html_safe($sizeNameMap[$tmpData['size_id']]);?> 像框<img src="images/line3.gif" width="21" height="12" /><?php  echo Util::html_safe($tmpData['frame_name']);?> <?php if($tmpData['is_gift'] == 'Y'):?>
     		 <span> (贈品) </span>
     		 <?php endif;?></li>
     <?php endforeach;?> 
     </ul>
     </div>
     <div class="maina-2">
    <ul>
      <?php foreach($orderInfo['gift_list'] as $tmpData):?>
    		<li class="maina-1a"><?php echo  Util::html_safe($tmpData['gift_name']);?><img src="images/line3.gif" width="21" height="12" /><?php echo  Util::html_safe($tmpData['number']);?>盒 <?php if($tmpData['is_gift'] == 'Y'):?>
     		 <span> (贈品) </span>
     		 <?php endif;?></li>
    	<?php endforeach;?>    
    </ul>
    </div>
    <div class="maina-2">
    <ul>
      <li class="maina-1c">
        備註<img src="images/line3.gif" width="21" height="12" />
 		<?php if($orderInfo['note_list']):?>
      <?php foreach($orderInfo['note_list'] as $itIndex=>$tmpData):?>
      	<li class="maina-1c"><?php echo  date(constant('WEBSITE_DATE_TIME_FORMATE'),strtotime($tmpData['date']));?>&nbsp;&nbsp;<?php echo  $tmpData['content'];?> </li>
      <?php endforeach;?>
      <?php endif;?>      </li>
    </ul>
    </div>
    
   <div class="maina-2">
    <ul>
       <li class="maina-1b">
       拍照<img src="images/line3.gif" width="21" height="12" /> <?php if(strlen($orderInfo['workflow']['photo_time']) > 0):?> <?php echo date(constant('WEBSITE_DATE_TIME_FORMATE'),strtotime($orderInfo['workflow']['photo_time']));?><?php endif;?>
      </li>
      <li class="maina-1a">
       攝影師<img src="images/line3.gif" width="21" height="12" />
       <?php foreach($orderInfo['workflow']['photo_person_list'] as $tmpData):?>
       <?php echo $tmpData;?>&nbsp;
       <?php endforeach;?>
      </li>
      <li class="maina-1b">
       造型師<img src="images/line3.gif" width="21" height="12" />
       <?php foreach($orderInfo['workflow']['dress_person_list'] as $tmpData):?>
       <?php echo $tmpData;?>&nbsp;
       <?php endforeach;?>
      </li>
      
       <li class="maina-1a">
       看樣<img src="images/line3.gif" width="21" height="12" /> <?php if(strlen($orderInfo['workflow']['proof_time']) > 0):?> <?php echo date(constant('WEBSITE_DATE_TIME_FORMATE'),strtotime($orderInfo['workflow']['proof_time']));?><?php endif;?>
      </li>
      <li class="maina-1b">客服部<img src="images/line3.gif" width="21" height="12" />
      <?php foreach($orderInfo['workflow']['csr_list'] as $tmpData):?>
       <?php echo $tmpData;?>&nbsp;
       <?php endforeach;?></li>
      <li class="maina-1a">
       取件<img src="images/line3.gif" width="21" height="12" /> <?php if(strlen($orderInfo['workflow']['pickup_time']) > 0):?> <?php echo date(constant('WEBSITE_DATE_TIME_FORMATE'),strtotime($orderInfo['workflow']['pickup_time']));?><?php endif;?>
      </li>
      <li class="maina-1a">客服部<img src="images/line3.gif" width="21" height="12" />
      <?php foreach($orderInfo['workflow']['pickup_person_list'] as $tmpData):?>
       <?php echo $tmpData;?>&nbsp;
       <?php endforeach;?>
      </li>
    </ul>
    </div>
  </div><!-- end #maina //-->
  
  <div id="titc">
  <div class="tita-1">
    <h3>款項</h3>
  </div>
  <div class="tita-2"></div>
  </div>
  <div id="mainb" class="clearfix"><!-- start #mainb //-->
  <div class="maina-2">
    <ul>
      <?php
      foreach($orderInfo['pay_list'] as $tmpData)
      {
      	$discountCss = '';
      	if(strpos($tmpData['type'],'折扣') !== false)
      	{
      		$discountCss = '2';
      	}
      	?>
      	 <li class="maina-1b<?php echo $discountCss;?>"><?php echo Util::html_safe($tmpData['type']);?><img src="images/line3.gif" width="21" height="12" /> <?php echo date(constant('WEBSITE_DATE_TIME_FORMATE'),strtotime($tmpData['date']));?>
      </li>
      <li class="maina-1a_1<?php echo $discountCss;?>">
       金額<img src="images/line3.gif" width="21" height="12" />NT.<?php echo Util::html_safe($tmpData['amount']);?>
      </li>
      <li class="maina-1a_1<?php echo $discountCss;?>">
       經手人<img src="images/line3.gif" width="21" height="12" /><?php echo Util::html_safe($tmpData['csr']);?>
      </li>
      	<?php
      }
      ?>
    </ul>
    </div>
    <div class="maina-3">
    <ul>
        <li class="maina-1c">消費金額<img src="images/line3.gif" width="21" height="12" />NT.<?php echo Util::html_safe($orderInfo['price']['total']);?>
      </li>
      <li class="maina-1c">
       已付款項<img src="images/line3.gif" width="21" height="12" />NT.<?php echo Util::html_safe($orderInfo['price']['pre_pay']);?>
      </li>
      <li class="maina-1c">
       結餘款項<img src="images/line3.gif" width="21" height="12" />NT.<?php echo Util::html_safe($orderInfo['price']['need_pay']);?>
      </li>
    </ul>
    </div>
    </div><!-- end #maina //-->
    <div id="pageb"><!-- start #pagea //-->
    <!--div id="pagee" ><a href="cos.php"><img src="images/pageb-prev.gif" width="81" height="29" /></a></div-->
    <div id="pagef" >
    <a href="#" onclick="javascript:edit_tol(1118);return false;"><img src="images/pay-story-btn.gif" width="81" height="29" /></a> 
    <a href="cosb.php?act=setstatus&status=new&id=<?php echo $orderManager->getId();?>"><img src="images/reorder-btn.gif" width="81" height="29" /></a>
    <a href="search.php?act=search&customer_name=<?php echo Util::html_safe($orderInfo['customerinfo']['name']);?>"><img src="images/pay-btn.gif" width="116" height="29" /></a>
    </div>
  </div><!-- end #pagea //-->
      
</div><!-- end #main //-->

 
<?php include 'page_footer.php';?>